﻿CREATE PROCEDURE [dbo].[ETL_SP_GetSummary4TaskList]
AS
select top(5) T.Id,
	T.Name,
	T.RunMode,
	TER.BatchId,
	TER.CreatedTime as ExecutedTime,
	TER.DataCount,
	TER.InsertSuccessCount
from ETL_Task as T
	left join (select MAX(TER.CreatedTime) as ExecutedTime,
			TER.TaskId 
		from ETL_TaskExecuteRecord as TER group by TER.TaskId) as TER2 on TER2.TaskId = T.Id
	left join ETL_TaskExecuteRecord as TER on TER.TaskId = T.Id and TER.CreatedTime = TER2.ExecutedTime
order by ExecutedTime desc
